#!gpxe
<%#
kind: iPXE
name: AutoYaST default iPXE
model: ProvisioningTemplate
oses:
- SLES
- OpenSUSE
description: |
  The template to render iPXE installation script for SLES and OpenSUSE
  The output is deployed on the host's subnet TFTP proxy.
  See https://ipxe.org/scripting for more details
-%>
<%
extra_args = []
if host_param('http-proxy') && host_param('http-proxy-port')
  extra_args << "proxy=http://" + host_param('http-proxy') + ":" + host_param('http-proxy-port')
elsif host_param('http-proxy')
  extra_args << "proxy=http://" + host_param('http-proxy')
end
-%>
echo Trying to ping Gateway: ${netX/gateway}
ping --count 1 ${netX/gateway} || echo Ping to Gateway failed or ping command not available.
echo Trying to ping DNS: ${netX/dns}
ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not available.

<% boot_files_uris = @host.operatingsystem.boot_files_uri(medium_provider) -%>
<% kernel = boot_files_uris[0] -%>
<% initrd = boot_files_uris[1] -%>

<% subnet = @host.subnet -%>
<% if subnet.respond_to?(:dhcp_boot_mode?) && subnet.dhcp_boot_mode? -%>
kernel <%= kernel %> initrd=initrd.img splash=silent install=<%= medium_uri %> autoyast=<%= foreman_url('provision') %> text-mode=1 useDHCP=1 <%= extra_args.join(' ')%>
<% else -%>
kernel <%= kernel %> initrd=initrd.img splash=silent install=<%= medium_uri %> autoyast=<%= foreman_url('provision') %> text-mode=1 useDHCP=0 netsetup=-dhcp ifcfg=*="${netX/ip}/<%= @host.primary_interface.subnet.cidr -%>,${netX/gateway},${dns},<%= @host.domain %>" <%= extra_args.join(' ')%>
<% end -%>
initrd <%= initrd %>
boot
